<form id="mainform" name='frm' method=post action="">
	<div id="toolbar-button">
			<div class="item" onclick="add()" id="itemButton1" title="Thêm mới">
				<div id="addnew-global-button"></div>
			</div>
			<div class="item" onclick="del()" id="itemButton0" title="Xóa">
				<div id="delete-global-button"></div>
			</div>			
	</div>
    <table width = 100% id="id-form">
        <tr>
            <td width="10%" nowrap="nowrap">Tên tỉnh thành
            </td>
            <td >
                <input type="text" class="inp-form" name="name" value="<?=$this->name ?>" size=25>
            </td>
        </tr>
        <tr>
            <td nowrap="nowrap"></td>
            <td><input type='button' onclick="timkiemAction()" value="Tìm kiếm">
            </td>
        </tr>
    </table >
    <table style="margin-top: 10px" border="0" width="100%" cellpadding="0" cellspacing="0" id="product-table">
        <thead>
            <tr class="alternate-row">
                <th width="5%" style="text-align: center" nowrap valign="left">
                    <input type=checkbox name=DELALL onclick="SelectAllU(this,'DEL')">
                </th>				
                <th width="5%" style="text-align: center" nowrap="nowrap">STT</th>
                <th style="text-align: left">Tên Tỉnh thành</th>
            </tr>
        </thead>
        <tfoot>
        </tfoot>
        <tbody>
            <?php
if (count($this->data) == 0) {
	echo "<tr><td colspan=3>Không có dữ liệu nào được tìm thấy</td></tr>";
} else {
	$stt = 1;
}
foreach ($this->data as $item) {
			   ?>
            <tr>
				<td style="text-align: center">
                    <input id="<?=$item['CITYID'] ?>" type="checkbox" name="DEL[]" value="<?=$item['CITYID'] ?>" />
                </td>
                <td style="text-align: center" ><?=$stt ?></td>               
                <td> 
                <a href="#" onClick="ItemClickU(<?php echo $item['CITYID'] ?>)">
                        <?=$item['NAME']; ?></a>
                </td>
            </tr>
            <?php $stt++;
																																				  }
				 ?>
        </tbody>
    </table>

</form>
<script>
    function ItemClickU(id)
    {
         document.frm.action = "/city/danhmuctinhthanh/input/id/"+id;
         document.frm.submit();
    }
    function add(){
        document.location.href='/city/danhmuctinhthanh/input';
    }
    function SelectAllU(selobj,childobj){
         var arr = document.getElementsByName(childobj+"[]");
         for(var i=0;i<arr.length;i++){
            arr[i].checked = selobj.checked;
         }
    }
    function timkiemAction(){
        common.submitForm(document.frm,'');
    }
    function del()
    {
    	  var ln = 0;
          var arr = document.getElementsByName('DEL[]');
          for(var i = 0 ; i < arr.length ;i++ )
          {
                  if(arr[i].checked == true)
                  {
                          ln = 1;
                          break;
                  }
          }
          
          if(ln == 1)
          {
                  if(confirm("<?php echo "Bạn có muốn xóa không"; ?>")){
                          document.frm.action="/city/danhmuctinhthanh/delete";
                          document.frm.method="post";
                          document.frm.submit();
                  }
          }
          else
          {
                  alert("Bạn phải một dòng chọn để xóa");
          }
    }

</script>
